/*
 * @Author: 陈少泉
 * @Date: 2021-09-13 14:11:48
 * @LastEditors: Baishui
 * @LastEditTime: 2021-09-28 20:26:03
 * @Description: file content
 */

import vue from '@vitejs/plugin-vue'
import ViteComponents, { AntDesignVueResolver } from 'vite-plugin-components'
import { viteMockServe } from 'vite-plugin-mock'

const path = require('path')

// https://vitejs.dev/config/
// export default defineConfig({
//   plugins: [vue()]
// })

export default ({ command, mode }) => {
  return {
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src'),
      },
    },
    plugins: [
      vue(),
      ViteComponents({
        customComponentResolvers: [AntDesignVueResolver()],
      }),
      viteMockServe({
        mockPath: 'mock',
        localEnabled: command === 'serve',
        prodEnabled: false,
        watchFiles: true,
        // logger: false, // 运行控制台打印日志
      }),
    ],
  }
}
